package com.iam.edu.ad.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.iam.edu.ad.entity.PromotionAd;
import com.iam.edu.ad.entity.PromotionSpace;
import com.iam.edu.ad.mapper.PromotionAdMapper;
import com.iam.edu.ad.service.IPromotionAdService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author kele
 * @since 2022-10-25
 */
@Service
public class PromotionAdServiceImpl extends ServiceImpl<PromotionAdMapper, PromotionAd> implements IPromotionAdService {

    @Override
    public List<PromotionAd> getByPromotionSpaceId(Integer spaceId) {

        Date now = new Date();
        LambdaQueryWrapper<PromotionAd> queryWrapper = Wrappers.lambdaQuery(PromotionAd.class)
                .eq(PromotionAd::getSpaceId, spaceId);
                //在有效期内
//                .gt(PromotionAd::getEndTime, now)
//                .lt(PromotionAd::getStartTime, now);

        return this.getBaseMapper().selectList(queryWrapper);
    }
}
